using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Hardware;

namespace MicroSnake
{
    class CreditsScreen : Screen
    {
        public CreditsScreen()
        {
            InitializeComponent();
        }

        private Image imgSnake;
        private Text txtTitle;
        private Text txtName;
        private Text txtWebSite;

        /// <summary>
        /// Built the menu graphical user interface
        /// </summary>
        private void InitializeComponent()
        {
            StackPanel stackPanel = new StackPanel(Orientation.Vertical);

            //this.Orientation = Orientation.Vertical;
            this.VerticalAlignment = VerticalAlignment.Center;

            txtTitle = new Text()
            {
                Font = Resources.GetFont(Resources.FontResources.NinaB),
                ForeColor = MicroSnakeColors.MenuTitleForeColor,
                HorizontalAlignment = HorizontalAlignment.Center,
                TextAlignment = TextAlignment.Center,
                TextContent = Resources.GetString(Resources.StringResources.DevelopedBy),
                VerticalAlignment = VerticalAlignment.Center,
            };
            txtTitle.SetMargin(5);

            stackPanel.Children.Add(txtTitle);

            txtName = new Text()
            {
                Font = Resources.GetFont(Resources.FontResources.NinaB),
                ForeColor = MicroSnakeColors.MenuTitleForeColor,
                HorizontalAlignment = HorizontalAlignment.Center,
                TextAlignment = TextAlignment.Center,
                TextContent = Resources.GetString(Resources.StringResources.Name),
                VerticalAlignment = VerticalAlignment.Center,
            };
            txtName.SetMargin(5);

            stackPanel.Children.Add(txtName);

            txtWebSite = new Text()
            {
                Font = Resources.GetFont(Resources.FontResources.NinaB),
                ForeColor = MicroSnakeColors.MenuItemForeColor,
                HorizontalAlignment = HorizontalAlignment.Center,
                TextAlignment = TextAlignment.Center,
                TextContent = Resources.GetString(Resources.StringResources.Website),
                VerticalAlignment = VerticalAlignment.Center,
            };
            txtWebSite.SetMargin(15);

            stackPanel.Children.Add(txtWebSite);

            imgSnake = new Image(Resources.GetBitmap(Resources.BitmapResources.Snake))
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
            };
            imgSnake.SetMargin(5);

            stackPanel.Children.Add(imgSnake);

            // Add event handler
            this.AddHandler(Buttons.ButtonDownEvent, new ButtonEventHandler(buttonDown), false);

            this.Children.Add(stackPanel);

            Buttons.Focus(this);
        }

        /*********************************************************************/
        /*                       Event Handling                              */
        /*********************************************************************/

        void buttonDown(object sender, ButtonEventArgs e)
        {
            ScreenManager.Instance.ShowMenuScreen();
        }
    }
}
